﻿using B.S.DataBase.MyProject.Domain.SaleOrders;
using B.S.DataBase.MyProject.ErrorCode;
using B.S.DataBase.MyProject.Infrastructure.Interface;
using MediatR;
using T.E.ERP.Read.API.Applicantions.Command.MyOrdermementCommands;

namespace T.E.ERP.Read.API.Applicantions.CommandHandler.MyOrdermementHandlers
{
    /// <summary>
    /// 销售订单命令处理
    /// </summary>
    public class ShouOrderHandler : IRequestHandler<ShouOrderCommand, APIResult<List<ShouOrder>>>
    {
        private readonly IBaseRepository<ShouOrder> _ShouOrder;

        public ShouOrderHandler(IBaseRepository<ShouOrder> shouOrder)
        {
            _ShouOrder = shouOrder;
        }

        public Task<APIResult<List<ShouOrder>>> Handle(ShouOrderCommand request, CancellationToken cancellationToken)
        {
            var result = new APIResult<List<ShouOrder>>()
            {
                Code = APIEnum.查询成功,
                Msg = APIEnum.查询失败.ToString()
            };
            var list= _ShouOrder.GetAll().Result.ToList();
            result.data = list;
            return Task.FromResult(result);
        }
    }
}
